'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;

  // home 模块
  router.get('/', controller.home.index);
  router.get('/api/home/carousels', controller.home.carousels);

  // user 模块
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/register', controller.user.register);
  router.post('/api/user/mail', controller.home.sendSuccessResponse);

  // projects 模块
  router.get('/api/projects', controller.project.index);

  // dirs 模块
  router.get('/api/dirs', controller.dir.index);

  // docs 模块
  router.get('/api/docs/:id', controller.doc.index);

  // 创建资源/修改资源/删除资源 -> 全部默认成功就可以
  router.post('/api/projects', controller.home.sendSuccessResponse);
  router.patch('/api/project/:id', controller.home.sendSuccessResponse);
  router.delete('/api/project/:id', controller.home.sendSuccessResponse);

  router.post('/api/dirs', controller.home.sendSuccessResponse);
  router.patch('/api/dirs/:id', controller.home.sendSuccessResponse);
  router.delete('/api/dirs/:id', controller.home.sendSuccessResponse);

  router.post('/api/docs', controller.home.sendSuccessResponse);
  router.patch('/api/docs/:id', controller.home.sendSuccessResponse);
  router.delete('/api/docs/:id', controller.home.sendSuccessResponse);
};
